<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        td{
            text-align: center;
        }
    </style>
</head>
<body>
    <table border="1px" cellpadding="10px" width="50%" >
        <tr>
            <th>
                <input type="button" name="" value="全选" id="all" onclick="chooseAll()">
                <input type="button" name="" value="全不选" id="none" onclick="chooseNone()">
                <input type="button" name="" value="反选" id="rechoose" onclick="reChoose()">

            </th>
            <th>分类ID</th>
            <th>分类名称</th>
            <th>分类描述</th>
        </tr>
        <tr>
            <td><input type="checkbox" name="cb"></td>
            <td>2</td>
            <td>手机数码</td>
            <td>手机数码类商品</td>
        </tr>
        <tr>
            <td><input type="checkbox" name="cb" ></td>
            <td>2</td>
            <td>手机数码</td>
            <td>手机数码类商品</td>
        </tr>
        <tr>
            <td><input type="checkbox" name="cb"  ></td>
            <td>3</td>
            <td>手机数码</td>
            <td>手机数码类商品</td>
        </tr>
        <tr>
            <td><input type="checkbox" name="cb" ></td>
            <td>4</td>
            <td>手机数码</td>
            <td>手机数码类商品</td>
        </tr>
        <tr>
            <td><input type="checkbox" name="cb" ></td>
            <td>5</td>
            <td>手机数码</td>
            <td>手机数码类商品</td>
        </tr>
    </table>
    <script>
        function chooseAll() {
            let cbs = document.getElementsByName("cb");
            for (let cb of cbs){
                cb.checked = true;
            }
        }
        function chooseNone() {
            let cbs = document.getElementsByName("cb");
            for (let cb of cbs){
                cb.checked = false;
            }
        }
        function reChoose() {
            let cbs = document.getElementsByName("cb");
            for (let cb of cbs){
                if (cb.checked == false){
                    cb.checked = true;
                }else {
                    cb.checked = false;
                }
            }
        }
    </script>
</body>
</html>